package controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import modelo.Cliente;
import modelo.ClienteDAO;

import vista.VentanaRegistrarCliente;


public class ControladorRegistrarCiente implements KeyListener, ActionListener, MouseListener {
     private VentanaRegistrarCliente vRegistrarCliente;
     private ClienteDAO clienteDAO;
     private Cliente cliente;
	 private boolean encontro;
	
	
	 
	 public ControladorRegistrarCiente(
			VentanaRegistrarCliente vRegistrarCliente, Cliente cliente) {
		super();
		this.vRegistrarCliente = vRegistrarCliente;
		this.cliente = cliente;
		this.encontro = encontro;
	}
    

	public ControladorRegistrarCiente() {
		super();
		// TODO Auto-generated constructor stub
		this.vRegistrarCliente= new VentanaRegistrarCliente();
		this.vRegistrarCliente.setVisible(true);
		this.vRegistrarCliente.setLocationRelativeTo(null);
		this.vRegistrarCliente.agregarListener(this,this,this);
		this.clienteDAO = new ClienteDAO();
	}


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
       new ControladorRegistrarCiente();
	}


	@Override
	public void keyTyped(KeyEvent e) {

	}


	
	@Override
	public void keyPressed(KeyEvent e) {
			}

	@Override
	public void keyReleased(KeyEvent e) {
		
	}

	private void busquedaPredictiva(KeyEvent e) {
		// TODO Auto-generated method stub
         
	}


	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		if(e.getActionCommand().equalsIgnoreCase("Buscar")){
			buscarCliente();
		} else if(e.getActionCommand().equalsIgnoreCase("Guardar")){
			guardarCliente();
		} else if(e.getActionCommand().equalsIgnoreCase("Eliminar")){
			eliminarCliente();
		} else if(e.getActionCommand().equalsIgnoreCase("Salir")){
			
			vRegistrarCliente.dispose();
			
		} else if(e.getActionCommand().equalsIgnoreCase("Limpiar")){
			
			vRegistrarCliente.limpiar();
		}
		
		
	}


	@Override
	public void mouseClicked(MouseEvent e) {
			}


	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}


	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	
	private void buscarCliente() {
		// TODO Auto-generated method stub
		
	}


	private void guardarCliente() {
		// TODO Auto-generated method stub
		
		if (vRegistrarCliente.validar()){
			
			
			
		} else {
			
			//mensaje debe llenar los campos obligatorios!
		}
		
	}


	private void eliminarCliente() {
		// TODO Auto-generated method stub
		
		
		
	}
	
	
	

}
